package com.lwj.springboot.config;

/**
 * @author LwJ
 * Created by LiWeijie on 2019/7/9.
 */
public class DynamicDataSourceContextHolder {

    private static final ThreadLocal<AreaKeyId> CURRENT_DATE_SOURCE = new ThreadLocal<>();

    /**
     * 清除当前数据源
     */
    public static void clear() {
        CURRENT_DATE_SOURCE.remove();
    }

    /**
     * 获取当前数据源
     *
     * @return
     */
    public static AreaKeyId get() {
        return CURRENT_DATE_SOURCE.get();
    }

    /**
     * 设置当前数据源
     *
     * @param areaKeyId
     */
    public static void set(AreaKeyId areaKeyId) {
        CURRENT_DATE_SOURCE.set(areaKeyId);
    }

}
